package d3_exceptiondeal;

import java.util.Scanner;

public class ExceptionTest4 {
    public static void main(String[] args) {
        while (true) {
            try {
                System.out.println(getmoney());
                break;
            } catch (Exception e) {
                System.out.println("Invalid money,Enter the valid number");
            }
        }
    }
    public static  double getmoney(){
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("Enter the money");
            double money =sc.nextDouble();
            if (money>=0){
                return money;
            }else{
                System.out.println("Invalid money");
            }
        }
    }
}
